package gwtmodule1.client.gui.utils;

public class Currency {

	private final static String unit = "USD";

	private float val;

	public Currency(float val) {
		super();
		this.val = val;
	}

	public String getFormated() {
		// what is an elegant way of formating floats in GWT as
		// String.format() doesn't exist??
		int i = (int) (val * 100);
		if ((i % 10) == 0)
			return String.valueOf(i / 100.0f) + "0";
		else
			return String.valueOf(i / 100.0f);
	}

	public String getFormatedWithUnit() {
		return getFormated() + " " + unit;
	}

	public String toString() {
		return getFormatedWithUnit();
	}

	public static String format(float val) {
		return new Currency(val).toString();
	}

}
